<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>系统设置</title>
		<link rel="stylesheet" type="text/css" href="skin/css/jquery.mobile-1.4.2.min.css"/>
		<script src="skin/js/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="skin/js/common.js" type="text/javascript" charset="utf-8"></script>
		<script src="skin/js/jquery.mobile-1.4.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
document.addEventListener( "plusready", update, false );

// 扩展API加载完毕，现在可以正常调用扩展 API

function update(){
	plus.io.requestFileSystem( plus.io.PRIVATE_DOC, function(fs){
		// fs.root是根目录操作对象DirectoryEntry
		fs.root.getFile('update.json',{create:true}, function(fileEntry){
			fileEntry.file( function(file){
				var fileReader = new plus.io.FileReader();
				//alert("getFile:" + JSON.stringify(file));
				fileReader.readAsText(file, 'utf-8');
				fileReader.onloadend = function(evt) {
					//fileEntry.remove();

					//alert("11" + evt);
					//alert("evt.target" + evt.target);
					data = JSON.parse(evt.target.result);
					//alert(data.server);
					document.getElementById("config").value = data.server;

				}
				//alert(file.size + '--' + file.name);
			} );
		});
	} );
}
function setting(){
	plus.io.requestFileSystem( plus.io.PRIVATE_DOC, function(fs){
		// fs.root是根目录操作对象DirectoryEntry
		fs.root.getFile('update.json',{create:true}, function(fentry){
			fentry.createWriter( function(writer){
                			writer.onerror = function(){
                				console.log( "获取升级数据，保存文件失败！" );
                			}
                			writer.write( '{ "server":"'+document.getElementById("config").value+'"}');
                		}, function(e){
                			console.log( "获取升级数据，创建写文件对象失败："+e.message );
                		} );
		});
	} );

}


</script>
	</head>
	<body>
		<div data-role="page">

			<div data-role="header" data-theme="c">
				<a href="#" onclick="pageback()" class="ui-btn ui-btn-icon-notext ui-icon-carat-l nobgbr">
					返回
				</a>
				<h1>系统设置</h1>
			</div><!-- /header -->

			<div role="main" class="ui-content">
				<form>
					<fieldset data-role="controlgroup">
					    <input type="text" name="config" id="config" class="" placeholder="服务器地址" value="">
					</fieldset>
					<input type="button" onclick="setting()" value="设置"/>
				</form>
			</div><!-- /content -->


			<div data-role="footer" data-position="fixed" data-theme="b">
				<div data-role="navbar">
					<ul>
						<li>
							<a href="member.html" data-icon="grid">
								员工管理
							</a>
						</li>
						<li>
							<a href="settings.html" data-icon="star">
								权限管理
							</a>
						</li>
						<li>
							<a href="order.html" data-icon="gear" class="ui-btn-active">
								订单管理
							</a>
						</li>
						<li>
							<a href="yuding.html" data-icon="gear">
								预订管理
							</a>
						</li>
					</ul>
				</div><!-- /navbar -->
			</div><!-- /footer -->

		</div><!-- /page -->

	</body>
</html>